import java.io.*;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.*;

class Schedule {
    private static int counter = 1;
    private int id;
    private String movieName;
    private String hall;
    private String time;
    private double price;
    private int totalSeats;
    private Set<Integer> soldSeats = new HashSet<>();

    public Schedule(String movieName, String hall, String time, double price, int totalSeats) {
        this.id = counter++;
        this.movieName = movieName;
        this.hall = hall; this.time = time; this.price = price; this.totalSeats = totalSeats;
    }

    public int getId() { return id; }
    public String getMovieName() { return movieName; }
    public boolean sellSeat(int seat) {
        if (seat < 1 || seat > totalSeats) return false;
        if (soldSeats.contains(seat)) return false;
        soldSeats.add(seat);
        return true;
    }
    public boolean refundSeat(int seat) { return soldSeats.remove(seat); }

    @Override
    public String toString() {
        return "场次ID:" + id + " 影片:" + movieName + " 厅:" + hall + " 时间:" + time +
                " 价格:" + price + " 总座位:" + totalSeats + " 已售:" + soldSeats.size();
    }
}